/*
 *      TwoOperandILToken.java
 *
 *      Copyright 2008 Pablo Nicolas Diaz Bilotto <pablonicolas.diaz@gmail.com>
 *
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

package ilanguage.iltokens.operations;

import ilanguage.iltokens.IL_SSA;
import lexer.EntryType;


/**
 * The Class TwoOperandILToken.
 */
public abstract class TwoOperandIL_SSA extends OneOperandIL_SSA {

	/** The Second arg. */
	private IL_SSA SecondArg;

	/**
	 * Instantiates a new two operand il token.
	 *
	 * @param firstToken the first token
	 * @param secToken the sec token
	 */

	public TwoOperandIL_SSA(final IL_SSA firstToken, final IL_SSA secToken) {
		this(firstToken, secToken, false);
	}

	/**
	 * Instantiates a new two operand il token.
	 *
	 * @param firstToken the first token
	 * @param secToken the sec token
	 * @param deffered the deffered
	 */
	public TwoOperandIL_SSA(final IL_SSA firstToken,
			final IL_SSA secToken, final boolean deffered) {
		super(firstToken);
		this.setSecondArg(secToken);
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see ILanguage.OneOperandIL_Token#GetPrefix()
	 */
	@Override
	public String getPrefix() {
		return super.getPrefix() + "," + getSecondArg().getValue();
	}

	/**
	 * Gets the second arg.
	 *
	 * @return the second arg
	 */
	public IL_SSA getSecondArg() {
		return SecondArg;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see ilanguage.SequenciableToken#isDiscartable()
	 */
	public boolean isDiscartable() {
		return super.isDiscartable() || OperationIL_SSA.discartable(getSecondArg());
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see ilanguage.OneOperandILToken#setReference(ilanguage.ILToken)
	 */
	@Override
	public void setReference(IL_SSA t) {
		this.setFirstArg(t);
	}

	/**
	 * Sets the second arg.
	 *
	 * @param secondArg the new second arg
	 */
	public void setSecondArg(IL_SSA secondArg) {
		SecondArg = secondArg;
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see ILanguage.OneOperandIL_Token#SolveTypes()
	 */
	@Override
	public EntryType solveTypes() {
		return EntryType.NOTYPE;
	}
}
